' Win32 SDK recommends the use of EnumFontFamiliesEx rather than the other versions:
Public Const LF_FACESIZE = 32
Public Const LF_FULLFACESIZE = 64
Type ENUMLOGFONTEX
elfLogFont As LOGFONT
elfFullName(LF_FULLFACESIZE) As Byte
elfStyle(LF_FACESIZE) As Byte
elfScript(LF_FACESIZE) As Byte
End Type
Type NEWTEXTMETRIC
tmHeight As Long
tmAscent As Long
tmDescent As Long
tmInternalLeading As Long
tmExternalLeading As Long
tmAveCharWidth As Long
tmMaxCharWidth As Long
tmWeight As Long
tmOverhang As Long
tmDigitizedAspectX As Long
tmDigitizedAspectY As Long
tmFirstChar As Byte
tmLastChar As Byte
tmDefaultChar As Byte
tmBreakChar As Byte
tmItalic As Byte
tmUnderlined As Byte
tmStruckOut As Byte
tmPitchAndFamily As Byte
tmCharSet As Byte
' Additional to TEXTMETRIC
ntmFlags As Long
ntmSizeEM As Long
ntmCellHeight As Long
ntmAveWidth As Long
End Type
Type FONTSIGNATURE
fsUsb(4) As Long
fsCsb(2) As Long
End Type
Type TEXTMETRIC
tmHeight As Long
tmAscent As Long
tmDescent As Long
tmInternalLeading As Long
tmExternalLeading As Long
tmAveCharWidth As Long
tmMaxCharWidth As Long
tmWeight As Long
tmOverhang As Long
tmDigitizedAspectX As Long
tmDigitizedAspectY As Long
tmFirstChar As Byte
tmLastChar As Byte
tmDefaultChar As Byte
tmBreakChar As Byte
tmItalic As Byte
tmUnderlined As Byte
tmStruckOut As Byte
tmPitchAndFamily As Byte
tmCharSet As Byte
End Type
Type NEWTEXTMETRICEX
ntmTm As NEWTEXTMETRIC
ntmFontSig As FONTSIGNATURE
End Type
' Declares:
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Declare Function EnumFontFamiliesEx Lib "gdi32" Alias "EnumFontFamiliesExA" (ByVal hdc As Long, lpLogFont As LOGFONT, ByVal lpEnumFontProc As Long, ByVal lParam As Long, ByVal dw As Long) As Long
Private m_lID As Long
'/* EnumFonts Masks */
Public Const RASTER_FONTTYPE = 1&
Public Const DEVICE_FONTTYPE = 2&
Public Const TRUETYPE_FONTTYPE = 4&
' Object to add items to:
Private m_ctl As OwnerDrawComboList
Private m_bPrinterFont As Boolean
Public Function GetFonts( _
ByVal lHDC As Long, _
ctl As OwnerDrawComboList, _
ByVal bPrinter As Boolean, _
Optional ByVal sFaceName As String = "" _
) As Long
Dim tLF As LOGFONT
Dim i As Integer
' No re-entrancy, please:
If Not (m_ctl Is Nothing) Then Exit Function
' Get the fonts:
m_bPrinterFont = bPrinter
Set m_ctl = ctl
m_lID = m_lID + 1
If Len(sFaceName) > 0 Then
For i = 1 To Len(sFaceName)
tLF.lfFaceName(i - 1) = Asc(Mid$(sFaceName, i, 1))